<%@page import="Interact.Interface"%>
<%@page import="Test.*"%>
<%@page import="DBModule.*"%>
<%@page import="Test.Course"%>
<%@page import="User.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>考试开始</title>
</head>
<body bgcolor='silver'>
<h1>开始考试</h1>
<form method="post" action="TestServlet?method=save">
<%
	// 取用户
	User user = (User)session.getAttribute("user");
	if (user == null || user.getType() != User.STUDENT){
		session.setAttribute("alert", "用户不存在或用户类型不是学生");
		response.sendRedirect("alert.jsp");
		return;
	}
	
	// 取科目
	
	Course course = (Course)session.getAttribute("course");
	
	if (course == null){
		session.setAttribute("alert", "未选择科目");
		response.sendRedirect("alert.jsp");
		return;
	}
	
	// 两个判断，八个应用题
	int types[] = {Judge.TYPE, Selection.TYPE, App.TYPE};
	int counts[] = {2, 4, 8};
	
	TestPaper paper = TestPaperManager.genRandowTestPaper(user, course, types, counts);
	
	// 放进session
	session.setAttribute("paper", paper);
	
	// 显示之
	Interface inf = new Interface(out);
	inf.print(paper);
	inf.flush();
%>
<input type="submit" value="提交">
</form>
</body>
</html>


